package cn.livingCloud.dto;

import cn.livingCloud.entity.core.Employee;
import cn.livingCloud.utils.DateUtils;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by DingJie on 2016/5/30.
 */
public class EmployeeFormDto {

    protected String createDateTime;
    protected Boolean archive;
    private String uuid;
    private String name;
    private String gender;
    private String age;
    private String phone;
    private boolean leader;
    private boolean inspector;
    //分类
    private String DeptName;
    private String deptUuid;
    private List<DeptDto> childDept = new ArrayList<>();

    private boolean continuation = false;

    public EmployeeFormDto() {
    }

    public EmployeeFormDto(Employee employee) {
        this.createDateTime = DateUtils.toDateText(employee.getCreateDateTime(), DateUtils.DEFAULT_DATE_TIME_FORMAT);
        this.archive = employee.getArchive();
        this.uuid = employee.getUuid();
        this.name = employee.getName();
        this.gender = employee.getGender();
        this.age = employee.getAge().toString();
        this.phone = employee.getPhone();
        this.deptUuid = employee.getDeptUuid();
        this.leader = employee.getIsLeader();
        this.inspector = employee.isInspector();
    }

    public String getCreateDateTime() {
        return createDateTime;
    }

    public void setCreateDateTime(String createDateTime) {
        this.createDateTime = createDateTime;
    }

    public Boolean getArchive() {
        return archive;
    }

    public void setArchive(Boolean archive) {
        this.archive = archive;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }


    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public boolean isLeader() {
        return leader;
    }

    public void setLeader(boolean leader) {
        this.leader = leader;
    }

    public String getDeptName() {
        return DeptName;
    }

    public void setDeptName(String deptName) {
        DeptName = deptName;
    }

    public String getDeptUuid() {
        return deptUuid;
    }

    public void setDeptUuid(String deptUuid) {
        this.deptUuid = deptUuid;
    }

    public List<DeptDto> getChildDept() {
        return childDept;
    }

    public void setChildDept(List<DeptDto> childDept) {
        this.childDept = childDept;
    }

    public boolean isInspector() {
        return inspector;
    }

    public EmployeeFormDto setInspector(boolean inspector) {
        this.inspector = inspector;
        return this;
    }

    public boolean isContinuation() {
        return continuation;
    }

    public EmployeeFormDto setContinuation(boolean continuation) {
        this.continuation = continuation;
        return this;
    }

    public void loadEmployee(Employee employee) {
        String value = DateUtils.toDateText(employee.getCreateDateTime(), DateUtils.DEFAULT_DATE_TIME_FORMAT);
        if (!StringUtils.isEmpty(value)) {
            this.createDateTime = value;
        }
        this.archive = employee.getArchive();
        this.uuid = employee.getUuid();
        this.name = employee.getName();
        this.gender = employee.getGender();
        this.age = employee.getAge().toString();
        this.phone = employee.getPhone();
        this.DeptName = employee.getDept().getName();
        this.deptUuid = employee.getDeptUuid();
        this.leader = employee.getIsLeader();
        this.inspector = employee.isInspector();
    }

    public void update(Employee employee) {
        employee.setDeptUuid(this.deptUuid);
        employee.setName(this.name);
        if (org.apache.commons.lang.StringUtils.isNotEmpty(this.age)) {
            employee.setAge(Integer.valueOf(this.age));
        }
        employee.setGender(this.gender);
        if (StringUtils.isNotEmpty(this.phone)) {
            employee.setPhone(this.phone);
        }
        employee.setIsLeader(this.leader);
        employee.setInspector(this.inspector);
    }
}
